package com.ruoyi.common.utils.baidu.entity;

/**
 * @author: jkk
 * @create: 2025/3/19-20:12
 * @Description:
 */
import java.util.List;

public class Polygon {
    private List<Point> path; // 多边形的点集合

    public Polygon(List<Point> path) {
        this.path = path;
    }

    public List<Point> getPath() {
        return path;
    }

    public Bounds getBounds() {
        // 计算外包矩形
        double minLng = Double.MAX_VALUE, minLat = Double.MAX_VALUE;
        double maxLng = Double.MIN_VALUE, maxLat = Double.MIN_VALUE;
        for (Point point : path) {
            minLng = Math.min(minLng, point.getLng());
            minLat = Math.min(minLat, point.getLat());
            maxLng = Math.max(maxLng, point.getLng());
            maxLat = Math.max(maxLat, point.getLat());
        }
        return new Bounds(new Point(minLng, minLat), new Point(maxLng, maxLat));
    }
}
